package com.sheliduan.itlearning.web.controller;

import com.sheliduan.itlearning.common.aspect.ApiOperationLog;
import com.sheliduan.itlearning.common.enums.ErrorCodeEnum;
import com.sheliduan.itlearning.common.exception.BizException;
import com.sheliduan.itlearning.common.utils.JsonUtil;
import com.sheliduan.itlearning.common.utils.ResponseData;
import com.sheliduan.itlearning.web.model.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.bind.BindResult;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.stream.Collectors;

/**
 * @author: 断舍离
 * @date: 2025/1/21 9:15
 * @description:
 **/
@RestController
@Slf4j
public class TestController {

    /*
    * @Validated用来告诉Spring需要对该参数进行校验
    * */
    @PostMapping("/test")
    @ApiOperationLog(description = "测试接口")
    public ResponseData test(@RequestBody @Validated User user){
        // 打印入参
        log.info(JsonUtil.toJsonString(user));
        // 设置日期字段值
        user.setCreateTime(LocalDateTime.now());
        log.info(JsonUtil.toJsonString(user));
        return ResponseData.success(user);
    }
}
